// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    wx.setStorageSync('logs', logs)
    let menuButton = wx.getMenuButtonBoundingClientRect()
    this.globalData.appInfo.menuButton = menuButton
    wx.getSystemInfo({
      success: (res) => {
        console.log(res);
        let statusBarHeight = res.statusBarHeight;
        const navBarHeight = menuButton.height + (menuButton.top - statusBarHeight) * 2 + 4; //导航高度
        this.globalData.appInfo.statusBarHeight = res.statusBarHeight
        this.globalData.appInfo.navBarHeight = navBarHeight
        this.globalData.appInfo.navHeight = statusBarHeight + navBarHeight
        this.globalData.appInfo.windowHeight = res.windowHeight
        this.globalData.appInfo.screenHeight = res.screenHeight
      }
    })
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
    Number.prototype[Symbol.iterator] = function* () {
      let i = 0;
      let num = this.valueOf();
      while (i < num) {
        yield i++;
      }
    }
  },
  globalData: {
    userInfo: null,
    appInfo: {
      capsuleButton: null
    }
  }
})